package org.springframework.security.oauth.samples.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

/**
 * Description:
 * Author: YangShiWei
 * Email: strongwalter2014@gmail.com
 * Datetime: 2023/9/3 22:02
 */
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
                .authorizeRequests()
                .antMatchers("/crcc-menhu/**")
                .hasAuthority("SCOPE_api_menhu")
                .and()
                .oauth2ResourceServer()
                .jwt()
//                .jwkSetUri("http://36.112.135.164:8099/discovery/certs")
                .jwkSetUri("https://regtest.crcc.cn/discovery/certs")
                .and()
        ;

    }
}
